<?php
/**
 * Remove a candidate from a mission
 * 
 * @package Mission
 * @author Xavier VILAIN
 */
use Hive\Mission\Partner;
use Hive\Mission;
$xview = Xview::instance();
$missionid = $xview->val('missionid');
$partnerid = $xview->val('partnerid');
if(!empty($partnerid)) {

	try {
		$mission = new Mission($missionid);
		$role = Partner::ROLE_CANDIDATE;
		$partner = $mission->findPartners($missionid.':'.$role.':'.$partnerid);
		$partner->delete();
		Fox\Message::Success(Msg(Hive::BUNDLE,Hive::REMOVE_FROM_MISSION,$partner->source()->name(),$mission->label()));
	}
	catch(Fox\Object\Exception\Save $e)
	{
		Fox\Message::Error($e->getMessage());
	}
	echo $xview->messages(false,true);
}